﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
namespace 三国题库
{
        public class SqlSugarContext
        {
            public static SqlSugarScope DB = new SqlSugarScope(
                new ConnectionConfig
                {
                    ConnectionString = "Data Source=Database.db3",
                    DbType = DbType.Sqlite,
                    IsAutoCloseConnection = true
                },
                db =>
                {
                    // 初始化表结构
                    db.CodeFirst.InitTables<QuestionDb>();
                    // 开启日志记录（输出到控制台）
                    db.Aop.OnLogExecuting = (sql, pars) =>
                    {
                        Debug.WriteLine(sql + "\r\n" + pars);
                    };
                }
            );

        }

        /// <summary>
        /// Question类，表示题库中的一个问题
        /// </summary>
        /// 
        [SugarTable("Question")]
        public class QuestionDb
        {
            [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
            public int id { get; set; }
            [SugarColumn(ColumnName = "答案")]
            public string answer { get; set; } = string.Empty;
            [SugarColumn(ColumnName = "首字母")]
            public string indexes { get; set; } = string.Empty;
            [SugarColumn(ColumnName = "问题")]
            public string? question { get; set; } = string.Empty;
        }
    
}
